﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.Configuration;
using System.Web.Script.Serialization;
using nplJobsBLL.ProcessJob;
using nplJobsBLL.ProcessEmployeer;
using nplJobsCommon.Employeer;
using nplJobsBLL.Common;
using nplJobsCommon.Common;
using nplJobsDAL.Select;

public partial class Employeer_PostNewJobs : BasePage // System.Web.UI.Page
{
    private string NEPAL_ID = WebConfigurationManager.AppSettings["NEPAL_ID"];//140 == Nepal
    private string KATHMANDU_ID = WebConfigurationManager.AppSettings["KATHMANDU_ID"];//29 == Kathmandu


    public string CompanyImageFolder
    {
        get
        {
            return WebConfigurationManager.AppSettings["COMPANY_IMAGE_FOLDER"];
        }
    }

    public string EmployeerID
    {
        get
        {
            if (Session["userInfo"] != null)
                return ((MembershipUser)Session["userInfo"]).ProviderUserKey.ToString();
            else
                return string.Empty;
        }
    }

    #region Load Inital DropDownLists

    #region  LoadJobCategory()
    /// <summary>
    ///This function loads job category
    /// </summary>
    public void LoadJobCategory()
    {
        try
        {
            ProcessJobCategory category = new ProcessJobCategory();
            category.invoke();
            ddlJobCategory.DataSource = category.JobCategory;
            ddlJobCategory.DataTextField = "Caterogy";
            ddlJobCategory.DataValueField = "ID";
            ddlJobCategory.DataBind();
        }
        catch (Exception exp)
        {
            throw new Exception(exp.Message.ToString());
        }
    }
    #endregion

    private Dictionary<int, int> GetAge()
    {
        Dictionary<int, int> lstAge = new Dictionary<int, int>();
        for (int i = 20; i < 60; i++)
        {
            lstAge.Add(i, i);
        }
        return lstAge;
    }

    private void LoadAgeFrom()
    {
        ddlAgeFrom.DataSource = this.GetAge();
        ddlAgeFrom.DataTextField = "Value";
        ddlAgeFrom.DataValueField = "Key";
        ddlAgeFrom.DataBind();
    }

    private void LoadAgeTo()
    {
        ddlAgeTo.DataSource = this.GetAge();
        ddlAgeTo.DataTextField = "Value";
        ddlAgeTo.DataValueField = "Key";
        ddlAgeTo.DataBind();
    }

    private void LoadAllDropDown()
    {
        LoadJobCategory();
        LoadAgeFrom();
        LoadAgeTo();
        LoadCarrerLevel();
        LoadJobType();
        LoadYearMin();
        LoadYearMax();
    }

    private void LoadCarrerLevel()
    {
        List<CareerLevel> lstCareerlevel = new SelectCareerLevel().GetCareerLevel();
        rdlJobLeveel.DataSource = lstCareerlevel;
        rdlJobLeveel.DataTextField = "Level";
        rdlJobLeveel.DataValueField = "ID";
        rdlJobLeveel.DataBind();
    }

    private void LoadJobType()
    {
        List<JobType> lstJobType = new nplJobsDAL.Select.SelectJobType().GetJobType();
        rdlJobType.DataSource = lstJobType;
        rdlJobType.DataTextField = "Type";
        rdlJobType.DataValueField = "ID";
        rdlJobType.DataBind();
        rdlJobType.Items[0].Selected = true;
    }

    private Dictionary<int, int> GetYears()
    {
        Dictionary<int, int> lstYears = new Dictionary<int, int>();
        for (int i = 1; i < 20; i++)
        {
            lstYears.Add(i, i);
        }
        return lstYears;
    }

    private void LoadYearMin()
    {
        ddlTotalYearsExpMin.DataSource = this.GetYears();
        ddlTotalYearsExpMin.DataTextField = "Value";
        ddlTotalYearsExpMin.DataValueField = "Key";
        ddlTotalYearsExpMin.DataBind();
    }

    private void LoadYearMax()
    {
        ddlTotalYearsExpMax.DataSource = this.GetYears();
        ddlTotalYearsExpMax.DataTextField = "Value";
        ddlTotalYearsExpMax.DataValueField = "Key";
        ddlTotalYearsExpMax.DataBind();
    }

    #endregion

    #region Page events
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Session["user"] != null && HttpContext.Current.Session["user"].Equals(General.Users.JobSeeker.ToString()))
        {
            Response.Redirect("../JobSeeker/EditProfile.aspx");
            return;
        }
        base.ReloadUserInfoSession();
        if (!IsPostBack)
        {
            MembershipUser currentUser = nplJobsWebSite.Common.CurrentMembershipUser;
            if (currentUser != null)
            {
                if (currentUser.UserName.Equals(WebConfigurationManager.AppSettings["NEWS_PAPER_USER"]))
                {
                    //Newspaper/Magazine                    
                }
                else if (currentUser.UserName.Equals(WebConfigurationManager.AppSettings["GUVERNMENT_USER"]))
                {
                    //Government Organizations
                }
                else
                {
                    divJobSource.Visible = false;
                }
            }

            LoadAllDropDown();
            LoadInitalData();

            Page.Title = "Posted new job";
        }
    }

    protected void asynPictureUpload_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        string fileExt = !String.IsNullOrEmpty(e.FileName) ? Path.GetExtension(e.FileName).ToLower() : String.Empty;
        if (asyncupload.HasFile && (fileExt == ".jpg" || fileExt == ".gif" || fileExt == ".png"))
        {
            if (Session["jobsImagePath"] != null && !string.IsNullOrEmpty(Session["jobsImagePath"].ToString()))
            {
                if (File.Exists(Server.MapPath(Session["jobsImagePath"].ToString())))
                {
                    //File.Delete(Server.MapPath(Session["jobsImagePath"].ToString()));
                }
            }
            string jobImagePath = "Jobs_" + nplJobsWebSite.Common.CurrentMembershipUser.ProviderUserKey + Path.GetExtension(e.FileName);
            string imagePath = "/" + CompanyImageFolder + "/" + jobImagePath;
            asyncupload.SaveAs(Server.MapPath(imagePath));
            Session["jobsImagePath"] = imagePath;

            string newFileName = "/" + CompanyImageFolder + "/" + "Jobs_" + nplJobsWebSite.Common.CurrentMembershipUser.ProviderUserKey + "_" + DateTime.Now.Ticks + Path.GetExtension(e.FileName);
            Session["jobsImageNewPath"] = newFileName;
        }
    }

    protected void imgNoPhoto_OnClick(object sender, EventArgs e)
    {
        imgNewJobImage.Attributes.Add("src", "../Images/no_photo_available.jpg");
        Session["jobsImagePath"] = null;
    }

    protected void btnSavePostJobs_Click(object sender, EventArgs e)
    {
        SavePostNewJobs();
    }

    #endregion

    #region SavePostNewJobs
    /// <summary>
    /// Save employeer entry
    /// </summary>
    private void SavePostNewJobs()
    {
        try
        {
            Job job = new Job();
            job.JobTitle = txtJobTitle.Text;
            job.JobCategoryID = Convert.ToInt32(ddlJobCategory.SelectedValue);
            job.JobResponsibilities = txtJobResponsibilities.Text;
            job.Vacancies = Convert.ToInt32(txtNoOfVacancies.Text);
            try
            {
                job.ApplicationDateline = DateTime.ParseExact(txtApplicationDeadline.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
            }
            catch (Exception ex) 
            {
                throw ex;
            }
            job.AgeRangeFrom = Convert.ToInt32(ddlAgeFrom.Text);
            job.AgeRangeTo = Convert.ToInt32(ddlAgeTo.Text);
            if (rblGender.SelectedItem != null)
                job.Gender = Convert.ToInt32(rblGender.SelectedItem.Value);
            if (rdlJobType.SelectedItem != null)
                job.JobTypeID = Convert.ToInt32(rdlJobType.SelectedItem.Value);
            if (rdlJobLeveel.SelectedItem != null)
            {
                job.CareerLevelID = Convert.ToInt32(rdlJobLeveel.Items[1].Selected ? 1 : 0);
                job.CareerLevelID = job.CareerLevelID + Convert.ToInt32(rdlJobLeveel.Items[2].Selected ? 2 : 0);
                job.CareerLevelID = job.CareerLevelID + Convert.ToInt32(rdlJobLeveel.Items[3].Selected ? 4 : 0);
            }
            job.Skills = txtSkills.Text;
            job.Qualifications = txtEducationalQualifications.Text;
            job.JobResponsibilities = txtJobResponsibilities.Text;
            if (chkRequiredExperience.SelectedItem != null)
                job.RequiredExperience = Convert.ToInt32(chkRequiredExperience.Items[0].Selected ? 0 : 1);
            job.IsCompanyInfoVisible = rblHideCompanyInfo.SelectedIndex == 0 ? true : false;
            if (!string.IsNullOrEmpty(hdnCityID.Value))
                job.CityID = Convert.ToInt32(hdnCityID.Value);
            if (!string.IsNullOrEmpty(hfContactPersonID.Value))
                job.ContactPersonID = Convert.ToInt64(hfContactPersonID.Value);

            if (rdoJobLocationType.SelectedItem != null)
                job.JobLocationType = Convert.ToInt32(rdoJobLocationType.SelectedItem.Value);

            job.isOnlineResume = chkApplicantResumeAs.Items[0].Selected ? true : false;
            job.isEmailAttachment = chkApplicantResumeAs.Items[1].Selected ? true : false; ;
            job.isHardCopy = chkApplicantResumeAs.Items[2].Selected ? true : false; ;
            job.IsPhotoEnclosed = rdoEnclosedPhotoCV.SelectedIndex == 0 ? true : false;
            job.InternalJobCode = txtInternalJobCode.Text;
            job.ApplicationInstructions = txtApplyInstructions.Text;
            job.Benefits = txtBenefits.Text;
            if (rdoSalaryRange.SelectedItem != null)
                job.SalaryRange = Convert.ToInt32(rdoSalaryRange.SelectedItem.Value);
            job.SalaryRangeMin = txtMinimum.Text;
            job.SalaryRangeMax = txtMaximum.Text;
            if (rdoJobPublishStatus.SelectedItem != null)
                job.JobPublishStatus = Convert.ToInt32(rdoJobPublishStatus.SelectedItem.Value);

            job.EmployeerID = Guid.Parse(this.EmployeerID);
            job.PostedDate = DateTime.Now;
            job.JobImagePath = "../Images/no_photo_available.jpg";

            if (chkRequiredExperience.Items[0].Selected)
            {
                job.TotalYearsOfExpMin = ddlTotalYearsExpMin.SelectedItem == null ? 0 : decimal.Parse(ddlTotalYearsExpMin.SelectedValue);
                job.TotalYearsOfExpMax = ddlTotalYearsExpMax.SelectedItem == null ? 0 : decimal.Parse(ddlTotalYearsExpMax.SelectedValue);
                job.ExperienceArea = txtExperienceAreaFields.Text;
            }
            job.KnownLanguage = txtKnownLanguage.Text;

            MembershipUser currentUser = nplJobsWebSite.Common.CurrentMembershipUser;
            if (currentUser != null)
            {
                if (currentUser.UserName.Equals(WebConfigurationManager.AppSettings["NEWS_PAPER_USER"]))
                {
                    job.JobSource = txtJobSource.Text; //Newspaper/Magazine
                }
                else if (currentUser.UserName.Equals(WebConfigurationManager.AppSettings["GUVERNMENT_USER"]))
                {
                    job.JobSource = txtJobSource.Text; //Government Organizations
                }
                else
                {
                    job.JobSource = "npljobs.com Online job posting";
                }
            }
            

            //job.SalaryID = txtJobTitle.Text;            
            //job.AlternativeCompanyName = txtJobTitle.Text;
            //job.IsDeleted = txtJobTitle.Text;            
            //job.IsContactPersonsVisible = txtJobTitle.Text;                        
            //job.Banner = txtJobTitle.Text;            
            //job.isGovtJob = false;
            ProcessJobEntry updateJob = new ProcessJobEntry();
            updateJob.Job = job;
            if (Request.QueryString["JobId"] == null)
            {
                updateJob.invoke();
            }
            else if (Request.QueryString["JobId"] != null && Request.QueryString["Action"] != null)
            {
                if (Request.QueryString["Action"].ToString() == "Edit")
                {
                    job.JobID = string.IsNullOrEmpty(hfJobId.Value) ? 0 : Convert.ToInt32(hfJobId.Value);
                    updateJob.Update();
                }
                else if (Request.QueryString["Action"].ToString() == "Repost")
                {
                    updateJob.invoke();
                }
            }

            updateJob.DeleteJobLocationWithin(job.JobID); // delete existing all cities

            #region InsertJobLocationWithin/Outside
            string str = hfContactJobCities.Value.Trim();
            if (rdoJobLocationType.SelectedItem.Value.Equals("1"))
            {
                //"5^9^5^~^5^10^3^~^^10^4^~^3^11^6^~^"
                string[] splitRow = str.Split("~".ToCharArray());
                foreach (string row in splitRow)
                {
                    if (!string.IsNullOrEmpty(row))
                    {
                        string[] splitCell = row.Split("^".ToCharArray());

                        int division = Convert.ToInt32(splitCell[0]);
                        int district = Convert.ToInt32(splitCell[1]);
                        int city = Convert.ToInt32(splitCell[2]);
                        updateJob.InsertJobLocationWithin(updateJob.LastJobID, division, district, city);
                    }
                }
            }
            else if (rdoJobLocationType.SelectedItem.Value.Equals("2"))
            {
                string[] splitRow = str.Split("~".ToCharArray());
                foreach (string row in splitRow)
                {
                    if (!string.IsNullOrEmpty(row))
                    {
                        string[] splitCell = row.Split("^".ToCharArray());

                        int Country = Convert.ToInt32(splitCell[0]);
                        string cityName = splitCell[1];
                        updateJob.InsertJobLocationOutside(updateJob.LastJobID, Country, cityName);
                    }
                }
            }

            #endregion

            //if (Session["jobsImagePath"] != null && Session["jobsImageNewPath"] != null)
            //{
            //    if (File.Exists(Server.MapPath(Session["jobsImagePath"].ToString())))
            //    {
            //        try
            //        {
            //            File.Move(Server.MapPath(Session["jobsImagePath"].ToString()), Server.MapPath(Session["jobsImageNewPath"].ToString()));
            //            Session["jobsImagePath"] = Session["jobsImageNewPath"];
            //            Session["jobsImageNewPath"] = null;
            //        }
            //        catch (Exception ex) {
            //            throw ex;
            //        }
            //    }
            //}
            Response.Redirect("PostedJobs.aspx");
        }
        catch (Exception exp)
        {
            lblMsg.Visible = true;
            lblMsg.Text = exp.Message;
        }
    }

    #endregion

    private string GetCity(int countryId, long cityId, string defaultCity)
    {
        ProcessSelectCity city = new ProcessSelectCity();
        city.countryID = countryId;
        city.invoke();

        City cty = city.City.Where(c => c.ID == cityId).FirstOrDefault();
        if (cty != null)
        {
            return cty.Name;
        }
        else
            return defaultCity;
    }

    private void LoadInitalData()
    {
        MembershipUser currentUser = nplJobsWebSite.Common.CurrentMembershipUser;
        if (currentUser != null)
        {
            Employeer employeer = nplJobsWebSite.Common.GetEmployeer((Guid)currentUser.ProviderUserKey);
            if (employeer != null)
            {
                txtContactCompanyName.Text = employeer.CompanyName;
                txtCity.Text = employeer.Country == 0 ? GetCity(Convert.ToInt32(NEPAL_ID), Convert.ToInt32(KATHMANDU_ID), employeer.CityName) : GetCity(employeer.Country, employeer.City, employeer.CityName);
                hdnCityID.Value = employeer.City.ToString();
            }

            if (Request.QueryString["JobId"] != null && Request.QueryString["Action"] != null)
            {
                Job job = SelectJobList.GetJobDetails(Convert.ToInt32(Request.QueryString["JobId"].ToString()));
                if (job.JobPublishStatus == 99)
                {
                    Response.Redirect("EmployeerEntry.aspx");
                }
                if (job != null)
                {
                    btnSavePostJobs.Text = "UPDATE";
                    if (Request.QueryString["Action"].ToString() == "Edit")
                    {
                        hfJobId.Value = job.JobID.ToString();
                        ddlJobCategory.Enabled = false;
                        ddlJobCategory.Attributes.CssStyle.Add("cursor", "not-allowed");
                        txtJobTitle.Enabled = false;
                    }
                    else if (Request.QueryString["Action"].ToString() == "Repost")
                    {
                        hfJobId.Value = "";
                        ddlJobCategory.Enabled = false;
                        ddlJobCategory.Attributes.CssStyle.Add("cursor", "not-allowed");
                        repostAttention.Style.Add("display", "block");
                        btnSavePostJobs.Text = "POST";
                    }

                    ddlJobCategory.SelectedValue = job.JobCategoryID.ToString();
                    txtJobTitle.Text = job.JobTitle;
                    txtNoOfVacancies.Text = job.Vacancies.ToString();
                    txtApplicationDeadline.Text = job.ApplicationDateline.ToString("dd/MM/yyyy");
                    ddlAgeFrom.SelectedValue = job.AgeRangeFrom.ToString();
                    ddlAgeTo.SelectedValue = job.AgeRangeTo.ToString();
                    rblGender.SelectedValue = job.Gender.ToString();
                    rdlJobType.SelectedValue = job.JobTypeID.ToString();

                    //rdlJobLeveel.Items[0].Selected = (job.CareerLevelID & 0) == 0;
                    rdlJobLeveel.Items[1].Selected = (job.CareerLevelID & 1) == 1;
                    rdlJobLeveel.Items[2].Selected = (job.CareerLevelID & 2) == 2;
                    rdlJobLeveel.Items[3].Selected = (job.CareerLevelID & 4) == 4;

                    txtSkills.Text = job.Skills;
                    txtEducationalQualifications.Text = job.Qualifications;
                    txtJobResponsibilities.Text = job.JobResponsibilities;

                    chkRequiredExperience.Items[0].Selected = job.RequiredExperience.Equals(0) ? true : false;
                    chkRequiredExperience.Items[1].Selected = job.RequiredExperience.Equals(1) ? true : false;

                    rblHideCompanyInfo.SelectedValue = job.IsCompanyInfoVisible ? "0" : "1";
                    hfContactPersonID.Value = job.ContactPersonID.ToString();
                    txtContactPerson.Value = job.ContactPerson;

                    rdoJobLocationType.SelectedValue = job.JobLocationType.ToString();

                    if (job.isOnlineResume)
                        chkApplicantResumeAs.Items[0].Selected = true;
                    if (job.isEmailAttachment)
                        chkApplicantResumeAs.Items[1].Selected = true;
                    if (job.isHardCopy)
                        chkApplicantResumeAs.Items[2].Selected = true;
                    rdoEnclosedPhotoCV.SelectedValue = job.IsPhotoEnclosed ? "0" : "1";
                    txtInternalJobCode.Text = job.InternalJobCode;
                    txtApplyInstructions.Text = job.ApplicationInstructions;
                    txtBenefits.Text = job.Benefits;
                    rdoSalaryRange.SelectedValue = job.SalaryRange.ToString();
                    if (job.SalaryRange.Equals(2))
                    {
                        DisplayRangePerMonth.Style.Add("display", "inline-block");
                        txtMaximum.Text = job.SalaryRangeMax;
                        txtMinimum.Text = job.SalaryRangeMin;
                    }

                    if (chkRequiredExperience.Items[0].Selected)
                    {
                        ddlTotalYearsExpMin.SelectedValue = job.TotalYearsOfExpMin.ToString();
                        ddlTotalYearsExpMax.SelectedValue = job.TotalYearsOfExpMax.ToString();
                        txtExperienceAreaFields.Text = job.ExperienceArea;
                    }
                    txtKnownLanguage.Text = job.KnownLanguage;
                    txtJobSource.Text = job.JobSource;

                    rdoJobPublishStatus.SelectedValue = job.JobPublishStatus.ToString();
                    if (!job.JobImagePath.Contains("no_photo_available"))
                    {
                        imgNewJobImage.Attributes.Add("src", job.JobImagePath);
                    }
                    else if (job.JobImagePath.Contains("no_photo_available"))
                    {
                        imgNewJobImage.Attributes.Add("src", "../Images/no_photo_available.jpg");
                    }
                    Session["jobsImageNewPath"] = job.JobImagePath;
                    //Session["jobsImagePath"] = Session["jobsImageNewPath"];
                }
            }
        }
    }

    #region WebMethod

    [WebMethod(EnableSession = true)]
    public static string GetCountrys()
    {
        ProcessCountry country = new ProcessCountry();
        country.invoke();

        return new JavaScriptSerializer().Serialize(country.Country.Where(w => w.ID > 1).ToList());
    }

    [WebMethod(EnableSession = true)]
    public static string GetDivisions()
    {
        ProcessDivision divisions = new ProcessDivision();
        divisions.invoke();
        return new JavaScriptSerializer().Serialize(divisions.Divisions);
    }

    [WebMethod(EnableSession = true)]
    public static string GetDistricts(string divisionId)
    {
        ProcessDistrict disticts = new ProcessDistrict();
        disticts.DivisionId = Convert.ToInt32(divisionId);
        disticts.invoke();
        return new JavaScriptSerializer().Serialize(disticts.Districts);
    }

    [WebMethod(EnableSession = true)]
    public static string GetCities(string districtId)
    {
        ProcessSelectCity cities = new ProcessSelectCity();
        cities.DistrictID = Convert.ToInt32(districtId);
        cities.GetCityByDistrict();
        return new JavaScriptSerializer().Serialize(cities.City);
    }

    [WebMethod(EnableSession = true)]
    public static string GetContactPerson(string contactPersonID)
    {
        ProcesEmployeerContactPerson procesEmployeerContactPerson = new ProcesEmployeerContactPerson();
        procesEmployeerContactPerson.employeerID = Guid.Parse(((MembershipUser)HttpContext.Current.Session["userInfo"]).ProviderUserKey.ToString());
        procesEmployeerContactPerson.contactPersonID = long.Parse(contactPersonID);
        procesEmployeerContactPerson.invoke();

        return new JavaScriptSerializer().Serialize(procesEmployeerContactPerson.employeerContactPerson.FirstOrDefault());
    }

    [WebMethod(EnableSession = true)]
    public static string GetContactsPerson()
    {
        ProcesEmployeerContactPerson procesEmployeerContactPerson = new ProcesEmployeerContactPerson();
        procesEmployeerContactPerson.employeerID = Guid.Parse(((MembershipUser)HttpContext.Current.Session["userInfo"]).ProviderUserKey.ToString());
        procesEmployeerContactPerson.invoke();

        return new JavaScriptSerializer().Serialize(procesEmployeerContactPerson.employeerContactPerson);
    }

    [WebMethod(EnableSession = true)]
    public static string GetServerTime()
    {
        return DateTime.Now.ToShortDateString();
    }


    [WebMethod(EnableSession = true)]
    public static bool HasCompanyDescription()
    {
        MembershipUser currentUser = nplJobsWebSite.Common.CurrentMembershipUser;
        if (currentUser != null)
        {
            Employeer employeer = nplJobsWebSite.Common.GetEmployeer((Guid)currentUser.ProviderUserKey);
            if (employeer != null)
            {
                if (string.IsNullOrEmpty(employeer.CompanyDescription.Trim()))
                    return false;
                else
                    return true;
            }
        }
        return false;
    }

    [WebMethod(EnableSession = true)]
    public static bool HasPostalAddress()
    {
        MembershipUser currentUser = nplJobsWebSite.Common.CurrentMembershipUser;
        if (currentUser != null)
        {
            Employeer employeer = nplJobsWebSite.Common.GetEmployeer((Guid)currentUser.ProviderUserKey);
            if (employeer != null)
            {
                if (string.IsNullOrEmpty(employeer.Address.Trim()))
                    return false;
                else
                    return true;
            }
        }
        return false;
    }

    [WebMethod(EnableSession = true)]
    public static int GetPostedJobsCount()
    {
        int result = 0;
        MembershipUser currentUser = nplJobsWebSite.Common.CurrentMembershipUser;
        if (currentUser != null)
        {
            result = SelectJobList.GetJobDetails((Guid)currentUser.ProviderUserKey).Count;
        }
        return result;
    }

    [WebMethod(EnableSession = true)]
    public static int MakeSessionEmptry()
    {
        HttpContext.Current.Session["jobsImagePath"] = null;
        return 1;
    }

    [WebMethod(EnableSession = true)]
    public static string GetJobLocationCities(string jobId)
    {
        ProcessSelectCitiesByJob jobCities = new ProcessSelectCitiesByJob();
        jobCities.JobID = Convert.ToInt32(jobId);
        jobCities.invoke();

        return new JavaScriptSerializer().Serialize(jobCities.JobCities);
    }

    [WebMethod(EnableSession = true)]
    public static string GetJobLocationOutsideCities(string jobId)
    {
        ProcessSelectCitiesByJob jobCities = new ProcessSelectCitiesByJob();
        jobCities.JobID = Convert.ToInt32(jobId);
        jobCities.InvokeOutsideCities();

        return new JavaScriptSerializer().Serialize(jobCities.JobCities);
    }

    #endregion
}